<html>
<head>
<meta NAME="author" CONTENT="Peter Csizmadia">
    <script type="text/javascript" src="../../sh_main.js"></script>
    <script type="text/javascript" src="../../sh_javascript.js"></script>
    <script type="text/javascript" src="../../sh_html.js"></script>
    <link REL ="stylesheet" TYPE="text/css" HREF="../../sh_nedit.css" TITLE="Style">
<link REL ="stylesheet" TYPE="text/css" HREF="../../../marvinmanuals.css" TITLE="Style">
<title>MarvinSketch Example - Triggering molfile download from JavaScript, naming the applet</title>
</head>
<body onload="sh_highlightDocument();">

<h1>MarvinSketch Example - Triggering molfile download from JavaScript, naming the applet</h1>

Press the <b>Load</b> button to load &quot;caffeine.mol&quot; into the sketcher.

<p>

<center>
<form onSubmit="return false">
<input TYPE=BUTTON VALUE="Load" onClick="loadMol()">
</form>

<script LANGUAGE="JavaScript1.1" SRC="../../../marvin.js"></script>
<script LANGUAGE="JavaScript1.1">
<!--
function loadMol() {
	if(document.MSketch != null) {
		document.MSketch.setMol("../../../mols-2d/caffeine.mol");
	} else {
		alert("Cannot load molecule:\n"+
		      "no JavaScript to Java communication in your browser.\n");
	}
}
msketch_name = "MSketch";
msketch_begin("../../..", 540, 480);
msketch_param("scale", "60");
msketch_param("viewonly", "true");
msketch_end();
//-->
</script>
</center>

<blockquote>
<pre class="sh_html">
&lt;form onSubmit=&quot;return false&quot;&gt;
&lt;input TYPE=BUTTON VALUE=&quot;Load&quot; onClick=&quot;loadMol()&quot;&gt;
&lt;/form&gt;

&lt;script LANGUAGE=&quot;JavaScript1.1&quot; SRC=&quot;../../../<a HREF="../marvin.js.txt">marvin.js</a>&quot;&gt;&lt;/script&gt;
&lt;script LANGUAGE=&quot;JavaScript1.1&quot;&gt;
&lt;!--
</pre><pre class="sh_javascript">
function loadMol() {
	if(document.MSketch != null) {
		document.MSketch.<a HREF="../../../help/developer/applets/api/JMSketch.html#setMol(java.lang.String)">setMol</a>(&quot;../../../mols-2d/caffeine.mol&quot;);
	} else {
		alert(&quot;Cannot load molecule:\n&quot;+
		      &quot;no JavaScript to Java communication in your browser.\n&quot;);
	}
}
msketch_name = &quot;MSketch&quot;;
msketch_begin(&quot;../../..&quot;, 540, 480);
msketch_param(&quot;<a HREF="../../../help/developer/sketchman.html#parameters.scale">scale</a>&quot;, &quot;60&quot;);
msketch_param(&quot;<a HREF="../../../help/developer/sketchman.html#parameters.viewonly">viewonly</a>&quot;, &quot;true&quot;);
msketch_end();
</pre><pre class="sh_html">
//--&gt;
&lt;/script&gt;
</pre>
</blockquote>

<p>

Note that the function that loads the molecule should not be named
<b>load()</b>, because this name conflicts with a built-in JavaScript function
in Netscape 6 (and later versions). That is why we named it <b>loadMol()</b>
in this example.

<center><div class="lenia">&nbsp;</div></center>

<p>In some cases you don't have the molfile in an URL, and it would be easier
to pack it into the HTML as in the previous example.
<a HREF="js_io.html">You can also do that in JavaScript.</a>

</body>
</html>
